import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:xin_he/utils/xh_styles.dart';
import 'package:xin_he/utils/xin_he_image.dart';

import 'xin_he_back_money_reason_logic.dart';

class XinHeBackMoneyReasonPage extends StatelessWidget {
  XinHeBackMoneyReasonPage({Key? key}) : super(key: key);

  final logic = Get.put(XinHeBackMoneyReasonLogic());
  final state = Get.find<XinHeBackMoneyReasonLogic>().state;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: Colors.transparent,
      body: Obx(() => Column(children: [
        const Spacer(),
        Container(
          height: Get.mediaQuery.padding.bottom+310,
          width: Get.width,
          decoration: const BoxDecoration(
            color: Colors.white,
            borderRadius: BorderRadius.only(topLeft: Radius.circular(10),topRight: Radius.circular(10)),
          ),
          child: Column(children: [
            ///title
            Container(
              height: 34.5,
              padding: const EdgeInsets.symmetric(horizontal: 15),
              child: Row(
                mainAxisAlignment: MainAxisAlignment.spaceBetween,
                children: [
                  Text('  '),
                  Text('退款原因',style: TextStyle(color: XinHeStyle.black333FontColor,fontSize: 14,fontWeight: FontWeight.w600),),
                  GestureDetector(
                    onTap: (){
                      Get.back();
                    },
                    child: Container(
                        padding: EdgeInsets.all(8),
                        child: const XinHeAssetImage('assets/images/mine/sheet_close.png',width: 10,height: 10,)),
                  ),
                ],),


            ),

            Expanded(child: ListView.builder(
                padding: EdgeInsets.zero,
                physics: const NeverScrollableScrollPhysics(),
                itemCount: logic.titleList.length,
                itemBuilder: (ctx,index){
                  return Obx(() => Container(
                    height: 45,
                    padding: const EdgeInsets.symmetric(horizontal: 15),
                    child: Column(children: [
                      SizedBox(
                        height: 44.5,
                        child: Row(children: [
                          Text(logic.titleList[index],style: TextStyle(color: XinHeColor('#555555'),fontSize: 13),),
                          Spacer(),
                          ///选择
                          GestureDetector(
                            onTap: (){

                              if(logic.selectedIndex.value !=index){
                                logic.selectedIndex.value = index;
                              }else {
                                logic.selectedIndex.value =1000;
                              }

                            },
                            child: Padding(
                              padding: const EdgeInsets.only(left: 15),
                              child: XinHeAssetImage( logic.selectedIndex.value == index?'assets/images/cart/cart_selected.png' :'assets/images/cart/cart_unselected.png',width:18 ,height: 18,),
                            ),
                          ),
                        ],),
                      ),
                      Container(height: 0.5,width: Get.width,color: XinHeColor('#EEEEEE'),),
                    ],)
                  ));
                })),
            ///完成
            GestureDetector(
              onTap: (){
                Get.back();
              },
              child: Container(
                height: 45,
                margin:const EdgeInsets.symmetric(horizontal: 15),
                width: double.infinity,
                alignment: Alignment.center,
                decoration: BoxDecoration(
                  gradient: LinearGradient(colors: [ XinHeColor('##F89A30'), XinHeColor('#E84128')]),
                  borderRadius: BorderRadius.circular(22.5),
                ),
                child: const Text('完成',style: TextStyle(color: Colors.white,fontSize: 14),strutStyle: StrutStyle(forceStrutHeight: true),),
              ),
            ),
            SizedBox(height: Get.mediaQuery.padding.bottom+25,)

          ],),)
      ],)),
    );
  }
}
